<?php
include('global.php');				//引入全局主文件
$GLOBALS['pos'] = '<a href="book_by_class.php" target="_self">图书分类</a>&gt;&gt;<a href="book_view.php" target="_self">查看图书</a>';
$GLOBALS['title'] = '图书管理系统 - 查看图书';

$hotbooks = $action->_get_hot_books(5);	//读取热门图书
$tuijian  = $action->_get_tuijian(5);	//读取推荐图书
$click    = $action->_get_click(5);		//读取点击排行
if(isset($_GET['bookid']))
{
	$bookread = $action->_get_book_read($_GET['bookid']);	//查询图书
	if($bookread == '')
	{
		header('Location:book_by_class.php');
	}
}
else
{
	header('Location:book_by_class.php');
}
?>
<?php include('public/top.php');//引入头?>
<div class="lefttoright">
  <div class="left1">
    <h1>热门借阅</h1>
    <ul>
    <?php
	if(!empty($hotbooks))
	{
    	foreach($hotbooks as $v)
		{
			echo '<li><a href="book_view.php?bookid=' . $v['bid'] . '">' . $v['name'] . '</a><em><img src="style/image/hot.gif" /></em></li>';
		}
	}
	else
	{
		echo '<li>暂无图书</li>';
	}
	?>
    </ul>
    </div>
  <div class="left1">
    <h1>推荐图书</h1>
    <ul>
    <?php
	if(!empty($tuijian))
	{
		foreach($tuijian as $val)
		{
    		echo '<li><a href="book_view.php?bookid=' . $val['bid'] . '">' . $val['name'] . '</a><em><img src="style/image/tuijian.gif" /></em></li>';
		}
	}
	else
	{
		echo '<li>暂无图书</li>';
	}
	?>
    </ul>
    </div>
  <div class="left1">
    <h1>总点击排行</h1>
    <ul>
    <?php
	if(!empty($click))
	{
		foreach($click as $v)
		{
			echo '<li><em>' . $v['click'] . '次</em><a href="book_view.php?bookid=' . $v['bid'] . '">' . $v['name'] . '</a></li>';
		}
	}
	else
	{
		echo '<li>暂无图书</li>';
	}
	?>
    </ul>
    </div>
</div>
<div class="righttoleft">
      <div class="rclass">
            <h2>查看图书</h2>
            <div class="field5">
				<table class="no">
                	<tr>
                    	<td width="20%">图书名称：</td>
                    	<td width="20%"><?php echo isset($bookread['name']) ? $bookread['name'] : '';?></td>
                    	<td width="60%" rowspan="5" colspan="2">
                        <img src="<?php echo !empty($bookread['pic']) ? substr($bookread['pic'], 3) : 'style/image/no-pic.jpg';?>" width="200" height="250" />
                        </td>
                    </tr>
                	<tr>
                    	<td>出版社：</td>
                    	<td><?php echo isset($bookread['pstore']) ? $bookread['pstore'] : '';?></td>
                    </tr>
                	<tr>
                    	<td>作者：</td>
                    	<td><?php echo isset($bookread['author']) ? $bookread['author'] : '';?></td>
                    </tr>
                	<tr>
                    	<td>出版时间：</td>
                    	<td><?php echo isset($bookread['pdate']) ? $bookread['pdate'] : '';?></td>
                    </tr>
                	<tr>
                    	<td>入库时间：</td>
                    	<td><?php echo isset($bookread['indate']) ? $bookread['indate'] : '';?></td>
                    </tr>
                	<tr>
                    	<td>价格：</td>
                    	<td><?php echo isset($bookread['price']) ? $bookread['price'] : '';?>&nbsp;元</td>
                    	<td>页数：</td>
                    	<td><?php echo isset($bookread['page']) ? $bookread['page'] : '';?>&nbsp;页</td>
                    </tr>
                	<tr>
                    	<td>是否推荐：</td>
                    	<td><?php echo isset($bookread['tuijian']) || $bookread['tuijian'] == 1 ? '推荐' : '不推荐';?></td>
                    	<td>点击量：</td>
                    	<td><?php echo isset($bookread['click']) ? $bookread['click'] : '';?>&nbsp;次</td>
                    </tr>
                	<tr>
                    	<td>可借复本：</td>
                    	<td><?php echo isset($bookread['storage']) ? $bookread['storage'] : '';?>&nbsp;本</td>
                    	<td>借阅：</td>
                    	<td><?php echo isset($bookread['times']) ? $bookread['times'] : '';?>&nbsp;次</td>
                    </tr>
                	<tr>
                    	<td>简介：</td>
                    	<td colspan="2"><?php echo !empty($bookread['content']) ? $bookread['content'] : '暂无简介';?></td>
                        <td>&nbsp;</td>
                    </tr>
                	<tr>
                    	<td>&nbsp;</td>
                    	<td colspan="2">
                <a href="book_borrow_back.php?act=add_collect&bid=<?php echo $bookread['bid'];?>" class="shoucang">收藏此书</a>
                <a href="book_borrow_back.php?act=borrow&bid=<?php echo $bookread['bid'];?>" class="jieyue">借阅此书</a>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
                <div class="clr"></div>
            </div>
      </div>
</div>
<?php echo $copyright;?>
</body>
</html>